package org.file5.dao;

import java.util.Collection;
import java.util.List;

import org.file5.domain.BaseEntity;
import org.file5.domain.Category;
import org.file5.domain.Entity2Entity;
import org.file5.domain.Person;
import org.file5.util.DataBean;

import com.googlecode.objectify.Key;

/**
 * Generic dao interface for uniquely identifiable entities. <br/>
 * The entity is of type E <br/>
 * The key which uniquely identifies the entity is of type PK <br/>
 * <br/>
 * <br/>
 * The daos in this project are only supposed to return types of its respective
 * entity, collections of its entities or calculated primitive values (like
 * counts)
 * 
 * @param <E>
 *            The entity type
 * @param <PK>
 *            The entity identifier type
 * 
 * @author bertell
 */
public interface BaseDao {

	public <E extends BaseEntity> DataBean<E> getListByProperties(Class<E> entityClass, int startPosition,
			int maxResult,final Object ...params);

	public <E extends BaseEntity, E2 extends BaseEntity> DataBean<Entity2Entity<E, E2> > getEntity2EntitiesBy(int startPosition,
			int maxResult, E entity,Entity2Entity.Relation relation, E2 entity2,BaseEntity.STATUS e2eStatus);

	public <E extends BaseEntity, E2 extends BaseEntity>  Entity2Entity<E, E2> findEntity2Entity(E entity,Entity2Entity.Relation relation,
			E2 entity2);


	public <E extends BaseEntity> E find(Class<E> entityClass, Key<E> key);

	public <E extends BaseEntity> E find( Key<E> key);


//---------------


	/**
	 * Finds an entity by its uid
	 * 
	 * @param uid
	 * @return
	 */
	public <E extends BaseEntity> E find(Class<E> entityClass, String uid);

	/**
	 * Creates an new entity into persistent storage
	 * 
	 * @param entity
	 * @return Created entity
	 */
	public <E extends BaseEntity> E addUpdate(E entity);

	/**
	 * Removes an entity
	 * 
	 * @param entity
	 */
	public <E extends BaseEntity> void remove(E entity);





	public <E extends BaseEntity> void clearData(Class<E> entityClass);

}
